package xcmg.device.dao.mapper.warehouse;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import xcmg.device.dao.entity.warehouse.WarehouseAreaLocationDO;
import xcmg.device.service.vo.warehouse.AddWarehouseAreaLocationVO;
import xcmg.device.service.vo.warehouse.WarehouseAreaLocationVO;

import java.util.List;
import java.util.Map;

@Mapper
public interface WarehouseAreaLocationDOMapper {

    int insert(WarehouseAreaLocationDO record);

    int batchInsert(List<WarehouseAreaLocationDO> list);

    int batchUpdateInsert(List<WarehouseAreaLocationDO> list);

    WarehouseAreaLocationDO item(@Param("locationCode") String locationCode,@Param("orgId") String orgId);

    List<WarehouseAreaLocationDO> list(@Param("warehouseAreaId") String warehouseAreaId);

    int deleteByRowNoRange(AddWarehouseAreaLocationVO areaLocationVO);

    int deleteByAreaId(@Param("warehouseAreaId")String warehouseAreaId);

    Map<String, Object> findAllCode(@Param("locationCode") String locationCode, @Param("orgId") String orgId);

    int findNumByShelfNo(@Param("warehouseAreaId") String warehouseAreaId, @Param("shelfNo") String shelfNo);

    List<WarehouseAreaLocationDO> findShelfNoByAreaId(@Param("warehouseAreaId")String warehouseAreaId);

    int updateLocationDesc(WarehouseAreaLocationVO location);

    int selectShelfNo(AddWarehouseAreaLocationVO warehouseAreaLocationVO);

    String findShelfNo(@Param("warehouseAreaId") String warehouseAreaId, @Param("orgId") String orgId);

    String findkeeperId(@Param("name") String name, @Param("orgId") String orgId);

    /**
     * 查询已存在的货架数量
     *
     * @param warehouseCode
     * @param areaCode
     * @param shelfNo
     * @param orgId
     * @return
     */
    Integer countByLocation(@Param("warehouseCode") String warehouseCode, @Param("areaCode") String areaCode,
        @Param("shelfNo") String shelfNo, @Param("orgId") String orgId);

    /**
     * 查询货架最大值信息
     *
     * @param warehouseCode
     * @param areaCode
     * @param shelfNo
     * @param orgId
     * @return
     */
    WarehouseAreaLocationDO getMaxLocationCode(@Param("warehouseCode") String warehouseCode, @Param("areaCode") String areaCode,
        @Param("shelfNo") String shelfNo, @Param("orgId") String orgId);

    int deleteByShelfNo(@Param("warehouseAreaId") String warehouseAreaId, @Param("shelfNo") String shelfNo);

    int countByShelfNo(@Param("warehouseAreaId") String warehouseAreaId, @Param("shelfNo") String shelfNo);

    String getLocationDesc(@Param("locationCode") String warehouseAreaId);
}
